package wafa.jmsListener;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

import wafa.modelDocument.Document;

public class JmsProducer {
	private JmsTemplate jmsTemplate;

	

	public void envoyerMessage(final Document document) {

		System.out.println("ok");

		jmsTemplate.send(new MessageCreator() {
			public Message createMessage(final Session session)
					throws JMSException {
				return session.createObjectMessage(document);
			}
		});
		

		System.out.println("producteurrrrrrrrrrr"+Thread.currentThread().getId());
		System.out.println("ok2");		
		
	}

	public JmsTemplate getJmsTemplate() {
		return jmsTemplate;
	}

	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	}
}
